import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;


public class ThreadToContactConnectedUser extends Thread {
    String hostName;
    int portNumber;
    Socket connectionToReceiver;
    String MyHostName;
    
    public ThreadToContactConnectedUser(String host, int Port, String MyHostName) {
        this.MyHostName = MyHostName;
        this.hostName = host;
        this.portNumber = Port;
    }
    
    public void run() {
            try {
            	System.out.println("Adding new tab");
            	connectionToReceiver = new Socket(hostName, portNumber);
            	if ( connectionToReceiver == null ) {
            		System.out.println("Connection is null in Connecting users thread");
            		return;
            	}
                DataOutputStream dos = new DataOutputStream(connectionToReceiver.getOutputStream());
                dos.writeInt(7);
                dos.writeUTF(MyHostName);
                connectionToReceiver.close();
            } catch (UnknownHostException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
}